/**
 * @version    $Id: base.js 1982 2014-05-09 07:53:04Z qinjinpeng $
 */
 try {
    document.execCommand("BackgroundImageCache", false, true); //ie6背景为图片时抖动解决方案
} catch (e) { }

$(function(){
	//鼠标hover滑动门
	$("*[class*=tb_]").mouseover(
		function(){
			classname = $(this).attr("class").match(/tb_[0-9a-z]*/g)[0];
			var mark = classname.split("_")[1];
			var i = $(".tb_"+mark).index(this);
			$(".tb_"+mark).removeClass("current").eq(i).addClass("current");
			$(".tbc_"+mark).hide().eq(i).show();
		}
		)
	$("*[class*=tbc_]").each(function(){
		classname = $(this).attr("class").match(/tbc_[0-9a-z]*/g)[0];
		if( typeof tbgroup != "undefined" && classname==tbgroup ) $(this).hide();
		tbgroup = classname;
	})
	//鼠标点击滑动门
	$("*[class*=ctb_]").click(
		function(){
			classname = $(this).attr("class").match(/ctb_[0-9a-z]*/g)[0];
			var mark = classname.split("_")[1];
			var i = $(".ctb_"+mark).index(this);
			$(".ctb_"+mark).removeClass("current").eq(i).addClass("current");
			$(".ctbc_"+mark).hide().eq(i).show();
		}
		)
	$("*[class*=ctbc_]").each(function(){
		classname = $(this).attr("class").match(/ctbc_[0-9a-z]*/g)[0];
		if( typeof tbgroup != "undefined" && classname==tbgroup ) $(this).hide();
		tbgroup = classname;
	})
})

function setTab(name,cursel,n){
	for(i=1;i<=n;i++){
		var menu=document.getElementById(name+i);
		var con=document.getElementById("con_"+name+"_"+i);
		menu.className=i==cursel?"hover":"";
		con.style.display=i==cursel?"block":"none";
	}
}

/*
 * 修复ie6不支持fixed问题
 */
 $(function(){
 	if($.browser.msie && $.browser.version=="6.0"){
 		document.execCommand('BackgroundImageCache', false, true);
 		$('body').css('backgroundAttachment') !== 'fixed' && $('html').css({
 			backgroundImage: 'url(about:blank)',
 			backgroundAttachment: 'fixed'
 		});
 		$("*").each(function(){
 			if($(this).css("position")=="fixed"){
 				this.style.position = 'absolute';
 				var top = $(this).css("top");
 				var bottom = $(this).css("bottom");
 				if(bottom){
 					top = $(window).height() - parseInt(bottom) - $(this).height();
 				}
 				if(top){
 					this.style.removeExpression('top');
 					this.style.setExpression('top', 'eval((document.documentElement).scrollTop + ' + parseInt(top) + ') + "px"');
 				}
 			}
 		})
 	}
 })

//兼容ie6任意dom hover focus
$(function(){
	$(".jq_hover").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	$(".jq_focus").focus(function(){
		$(this).addClass("focus");
	});
	$(".jq_focus").blur(function(){
		$(this).addClass("focus");
	});
})

function getCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			var endstr = document.cookie.indexOf(";", j);
			if (endstr == -1) {
				endstr = document.cookie.length
			}
			return document.cookie.substring(j, endstr);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break
	}
return ""
}

function setCookie(name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires: "") + ((path) ? "; path=" + path: "") + ((domain) ? "; domain=" + domain: "") + ((secure) ? "; secure": "")
}

